#include "atomic_0826_result_distribution_service.h"

// 简单模拟结果分发功能
int getResultDistribution(ResultDistributionInput *input, ResultDistributionOutput *output) {
    // 检查输入输出指针有效性
    if (input == nullptr || output == nullptr) {
        return ATOMIC_SERVICE_ERROR;
    }

    // 复制输入中的解算结果数据到输出
    output->solution_valid = input->solution_valid;
    output->sol_time = input->sol_time;

    // 位置信息复制
    output->latitude = input->latitude;
    output->longitude = input->longitude;
    output->altitude = input->altitude;
    output->pos_std_lat = input->pos_std_lat;
    output->pos_std_lon = input->pos_std_lon;
    output->pos_std_alt = input->pos_std_alt;

    // 速度信息复制
    output->velocity_east = input->velocity_east;
    output->velocity_north = input->velocity_north;
    output->velocity_up = input->velocity_up;
    output->vel_std_east = input->vel_std_east;
    output->vel_std_north = input->vel_std_north;
    output->vel_std_up = input->vel_std_up;

    // 姿态信息复制
    output->attitude_roll = input->attitude_roll;
    output->attitude_pitch = input->attitude_pitch;
    output->attitude_heading = input->attitude_heading;
    output->att_std_roll = input->att_std_roll;
    output->att_std_pitch = input->att_std_pitch;
    output->att_std_heading = input->att_std_heading;

    // 其他信息复制
    output->sensor_id = input->sensor_id;
    output->raw_error = input->raw_error;
    output->position_x = input->position_x;
    output->position_y = input->position_y;
    output->timestamp = input->timestamp;

    // 模拟分发结果：根据解算结果有效性设置成功/失败计数
    if (input->solution_valid == 1) {
        output->success_count = 3;  // 假设3个模块成功接收
        output->fail_count = 0;     // 0个模块接收失败
    } else {
        output->success_count = 0;  // 解算结果无效，所有模块接收失败
        output->fail_count = 3;
    }

    // 设置返回状态
    output->return_type = ATOMIC_SERVICE_SUCCESS;
    return ATOMIC_SERVICE_SUCCESS;
}